From: Sebastian Keller Date: Thu, 10 Sep 2026 22:13:24 +0000 (+0200) Subject: popupMenu: Disconnect signal handlers when child section is destroyed X-Git-Tag: archive/raspbian/50.5-1+rpi1^2~6^2^2~4 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=17510c7dd59c8a96af90d419d5bb5d29c25a8e43;p=gnome-shell.git popupMenu: Disconnect signal handlers when child section is destroyed Neither `PopupMenuBase` nor `PopupMenuSection` are destroyable, thus the signal connection needs to be manually disconnected to avoid leaking both via the respective signal trackers. This disconnects the connections in both directions when the child `PopupMenuSection` is destroyed, which handles both cases the section being destroyed, but also the parent menu being destroyed, because that also triggers the destruction of all children. Part-of: (cherry picked from commit 2a923660bc1212cc0249dbb8833d28a708f089c0) --- diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js index 463ecb28f..7dce5b661 100644 --- a/js/ui/popupMenu.js +++ b/js/ui/popupMenu.js @@ -879,7 +879,11 @@ export class PopupMenuBase extends Signals.EventEmitter { if (menuItem instanceof PopupMenuSection) { menuItem.connectObject( 'active-changed', this._subMenuActiveChanged.bind(this), - 'destroy', () => this.length--, this); + 'destroy', () => { + this.length--; + this.disconnectObject(menuItem); + menuItem.disconnectObject(this); + }, this); this.connectObject( 'open-state-changed', (self, open) => {